package flc.ast.adapter;

import android.view.View;

import androidx.annotation.NonNull;

import com.chad.library.adapter.base.viewholder.BaseDataBindingHolder;
import com.stark.calculator.tax.model.DeductionBean;

import flc.ast.R;
import flc.ast.databinding.ItemDeductionBinding;
import stark.common.basic.adapter.BaseDBRVAdapter;

public class MyDeductionAdapter extends BaseDBRVAdapter<DeductionBean, ItemDeductionBinding> {


    public MyDeductionAdapter() {
        super(R.layout.item_deduction, 0);
    }

    @Override
    protected void convert(@NonNull BaseDataBindingHolder<ItemDeductionBinding> holder, DeductionBean deductionBean) {
        ItemDeductionBinding binding = holder.getDataBinding();
        binding.tvDeductionItem.setText(deductionBean.getName());
        binding.tvDeductionValue.setText(deductionBean.getValue());
        if (deductionBean.isChecked()) {
            binding.ivDeductionSelect.setVisibility(View.VISIBLE);
        } else {
            binding.ivDeductionSelect.setVisibility(View.INVISIBLE);
        }
        if (getItemPosition(deductionBean)==getRealDataCount()-1){
            binding.vLine.setVisibility(View.GONE);
        }else {
            binding.vLine.setVisibility(View.VISIBLE);
        }
    }

}
